import Vue from 'vue'
import VueRouter from 'vue-router'


Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'manage',
    redirect:"/home",
    meta:{
      name:"主页"
    },
    component: () => import('../views/Manage'),
    children: [
      {
        path: '/home',
        name: '首页',
        meta:{
          name:""
        },
        component: () => import('../views/Home')
      },
      {
        path: '/person',
        name: '个人信息',
        meta:{
          name:"个人信息"
        },
        component: () => import('../views/Person')
      },
    ]
  },
  {
    path: '/system',
    name: 'system',
    meta:{
      name:"系统管理"
    },
    redirect: "/home",
    component: () => import('../views/Manage'),
    children: [
      {
        path: '/system/user',
        name: '用户管理',
        meta:{
          name:"用户管理"
        },
        component: () => import('../views/User')
      },
      {
        path: '/system/file',
        name: '文件管理',
        meta:{
          name:"文件管理"
        },
        component: () => import('../views/File')
      }
    ]
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/Login')
  },
  {
    path: '/regist',
    name: 'regist',
    component: () => import('../views/Regist')
  },
  {
    path: '/about',
    name: 'about',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

const originalPush = VueRouter.prototype.push

VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}


export default router
